package com.delos.rbac.service.impl;

import com.delos.rbac.entity.UserDO;
import com.delos.rbac.mapper.UserMapper;
import com.delos.rbac.service.IRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.stereotype.Service;

/**
 * @author zouyaowen
 * @date 2020-07-05
 */
@Service
public class RegisterServiceImpl implements IRegisterService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public void browserRegister(String userName, String password) {
        //数据加密
        String encryptPassword = BCrypt.hashpw(password, BCrypt.gensalt());
        UserDO userDO = new UserDO();
        userDO.setUserName(userName);
        userDO.setPassword(encryptPassword);
        userMapper.insert(userDO);
    }
}
